<?php
require_once FOREGROUND_COMMON_ACTION_SERVICE_DIR . '/default.php';

class foreground_order_info_action_service extends foreground_default_common_action_service
{
    protected static $_instance;

    public static function get_instance()
    {
        if (null === self::$_instance) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }


    protected function _current_page_process()
    {
        //var_dump(__METHOD__); exit();
        
        $result = array('status' => 0, 'message' => '', 'data' => array());
        
        self::add_view_data('page_title', '订单详情');
         
        $id = init_user_data_key($_GET, 'id', 'int');
    
        $action_data = wwy_action::$data;
	    $session_member_info = $action_data['session_member_info'];
        $member_id = $session_member_info['id'];
        
        if(empty($id)){
            $result['status']  = -2;
            $result['message'] = '订单错误';
        }else{
            $model_foreground_order = wwy_resource_container::get_model_foreground_order();
            //var_dump($model_foreground_order); exit();
            $where  = array(
                'id'        => $id,
                'member_id' => $member_id
            );
            $order_info = $model_foreground_order->fetch_row($where);
            //var_dump($order_info); exit();
            if(empty($order_info)){
                $result['status']  = -3;
                $result['message'] = '不存在该订单';
            }else{
                //$result['order_info'] = $order_info;
                self::add_view_data('order_info', $order_info);
            }                                
        }
        //exit();
    
        if($result['status'] == 0){
            $model_foreground_order_good = wwy_resource_container::get_model_foreground_order_good();
            $where = array('order_id' => $id);
            $order_good_list = $model_foreground_order_good->fetch_all($where);
            //var_dump($order_good_list); exit();
            //$result['order_good_list'] = $order_good_list;
            self::add_view_data('order_good_list', $order_good_list);
        }
        //exit();
        
        //self::add_view_data('message', $result['message']);        
        
        self::set_view_status($result['status']);
        self::set_view_message($result['message']);
    }
}